package com.manage.utils;

import com.manage.common.exception.HxException;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringTool {
    public static String addPrefixWithBuilder(String original, String prefix) {
        StringBuilder stringBuilder = new StringBuilder(prefix);
        stringBuilder.append(original);
        return stringBuilder.toString();
    }

    public static boolean checkIfStartsWithSlash(String str) {
        Pattern pattern = Pattern.compile("^/");
        Matcher matcher = pattern.matcher(str);
        boolean flag = matcher.find();
        if (flag) {
            return true;
        } else {
            throw new HxException("字符串没有以 / 开头！");
        }
    }

}
